#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
//#include "threadPool.hpp"
#include "threadPool_singleton.hpp"
#include "Task.hpp"

int main()
{
    const char *opts = "+-*/%";

    // 生产任务
    srand(time(nullptr) ^ getpid());
    
    // threadPool<Task> tp;
    // tp.start();


    while (true)
    {

        // int x = rand() % 100 + 1;
        // int y = rand() % 100 + 1;
        // char opt = opts[(x + y) % strlen(opts)];

        int x = 0, y = 0;
        char opt = 0;

        std::cout << "输入左操作数:> ";
        std::cin >> x;

        std::cout << "输入运算符(+-*/%):> ";
        std::cin >> opt;

        std::cout << "输入右操作数:> ";
        std::cin >> y;

        Task t(x, y, opt);
        // tp.pushTask(t);
        threadPool<Task>::get_instance()->pushTask(t);

        std::cout << "task: " << t.equation() << " " << "?" << std::endl;
    }
    

    return 0;
}